home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: Robert Kleemann <goose@ix.netcom.con>
- Newsgroups: comp.lang.c++
- Subject: Correct Ansi C++ behavior?
- Date: Fri, 19 Apr 1996 09:54:58 -0700
- Organization: Netcom
- Message-ID: <3177C562.7578@ix.netcom.con>
- NNTP-Posting-Host: sea-wa11-20.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-NETCOM-Date: Fri Apr 19 9:54:45 AM PDT 1996
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- The following code compiles cleanly with MS VC v4.0 but I believe the last
- line should result in an error. Does anyone know for certain whether this is
- a bug or correct C++ behavior? I don't have any other compilers to test it
- on.
-
- thanx!
- Robert
-
- class Bar;
-
- class Foo
- {
- public:
- Foo();
- Foo(const Foo& p);
- private:
- // only Bar member functions and friends can
- // create a Foo object from a Bar object
- Foo(const Bar& p);
- };
-
- class Bar
- {
- public:
- Bar();
- Bar(const Bar& p);
- // any function can create a Bar object
- // from a Foo object
- Bar(const Foo& p);
- private:
- };
-
- void main()
- {
- Foo f;
- Bar b;
- Bar b2(f); // legal
- b = Bar(f); // legal
- //Foo f2(b); // should be illegal and is
- f = Foo(b); // I believe this should also be illegal but it isn't
- }
-